package cn.hss.object.customer;

/**账户类
 * @author 作者：HeShaoShuai
 * @Email 邮箱：2569819541@qq.com
 * @Date 日期：2023/4/25 17:16
 * @Package 包名：cn.hss.object.customer
 * @Project 项目名：JavaSE
 * @Version 1.0
 */
public class Account {
	private int id;//账号
	private double balance;//余额
	private double rate;//年利率
	public Account(){}
	public Account(int id,double balance) {
		this();
		this.id = id;
		this.balance = balance;
	}

	//全参构造器
	public Account(int id,double balance, double rate) {
		this(id,balance);
		this.rate = rate;
	}

	@Override
	public String toString() {
		return "Account{" +
				"id=" + id +
				", balance=" + balance +
				", rate=" + rate +
				'}';
	}

	//存钱
	public void deposit(double amount){
		if(amount>0){
			balance += amount;
			System.out.println("成功存入："+amount);
		}
	}
	//取钱
	public void withdraw(double money){
		if(money <=balance && money > 0){
			balance -= money;
			System.out.println("成功取出："+money);
		}else{
			System.out.println("余额不足");
		}
	}

	public int getId() {
		return id;
	}

	public void setId(final int id) {
		this.id = id;
	}

	public double getBalance() {
		return balance;
	}

	public void setBalance(final double balance) {
		this.balance = balance;
	}

	public double getRate() {
		return rate;
	}

	public void setRate(final double rate) {
		this.rate = rate;
	}
}
